package message

import "fmt"

func Println(a ...interface{}) {
	if rwMutex.TryRLock() {
		defer rwMutex.RUnlock()
		outputChan.In <- message{
			Context: fmt.Sprintln(a...),
			Type:    "info",
		}
	}
}

func PrintWarn(a ...interface{}) {
	if rwMutex.TryRLock() {
		defer rwMutex.RUnlock()
		outputChan.In <- message{
			Context: fmt.Sprintln(a...),
			Type:    "warn",
		}
	}
}
func PrintErr(a ...interface{}) {
	if rwMutex.TryRLock() {
		defer rwMutex.RUnlock()
		outputChan.In <- message{
			Context: fmt.Sprintln(a...),
			Type:    "error",
		}
	}
}

func Exit(a ...interface{}) {
	if rwMutex.TryRLock() {
		defer rwMutex.RUnlock()
		outputChan.In <- message{
			Context: fmt.Sprint(a...),
			Type:    "exit",
		}
	}
}

func PrintRecover(a ...interface{}) {
	if rwMutex.TryRLock() {
		defer rwMutex.RUnlock()
		outputChan.In <- message{
			Context: a,
			Type:    "recover",
		}
	}
}
